package com.example;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * new Date()所做的事情其实就是调用了System.currentTimeMillis()
 * Joda Time
 *
 * DateTime dateTime = new DateTime();
 * System.out.println(dateTime.getSecondOfMinute());
 */
public class HelloController {
    public static void main(String[] args) {
        long a1 = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            System.currentTimeMillis();
        }
        System.out.println(System.currentTimeMillis()-a1);

        long a2 = System.currentTimeMillis();
        LocalDateTime localDateTime = LocalDateTime.now();
        for (int i = 0; i < 10000; i++) {
            localDateTime.getSecond();
        }
        System.out.println(System.currentTimeMillis()-a2);

        Date currentDate = new Date();
        System.out.println(currentDate.getTime()/1000L);
        // 这个效率更高
    }
}
